/*
 * Copyright 2010 Daniel Kurka
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.googlecode.gwtphonegap.showcase.client;

import com.google.gwt.activity.shared.Activity;
import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.place.shared.Place;
import com.googlecode.gwtphonegap.showcase.client.about.AboutActivity;
import com.googlecode.gwtphonegap.showcase.client.about.AboutPlace;
import com.googlecode.gwtphonegap.showcase.client.accelerometer.AccelerometerActivity;
import com.googlecode.gwtphonegap.showcase.client.accelerometer.AccelerometerPlace;
import com.googlecode.gwtphonegap.showcase.client.camera.CameraActivity;
import com.googlecode.gwtphonegap.showcase.client.camera.CameraPlace;
import com.googlecode.gwtphonegap.showcase.client.compass.CompassActivity;
import com.googlecode.gwtphonegap.showcase.client.compass.CompassPlace;
import com.googlecode.gwtphonegap.showcase.client.connection.ConnectionActivity;
import com.googlecode.gwtphonegap.showcase.client.connection.ConnectionPlace;
import com.googlecode.gwtphonegap.showcase.client.contact.ContactActivity;
import com.googlecode.gwtphonegap.showcase.client.contact.ContactPlace;
import com.googlecode.gwtphonegap.showcase.client.device.DeviceActivity;
import com.googlecode.gwtphonegap.showcase.client.device.DevicePlace;
import com.googlecode.gwtphonegap.showcase.client.event.EventActivity;
import com.googlecode.gwtphonegap.showcase.client.event.EventPlace;
import com.googlecode.gwtphonegap.showcase.client.file.FileActivity;
import com.googlecode.gwtphonegap.showcase.client.file.FilePlace;
import com.googlecode.gwtphonegap.showcase.client.geolocation.GeolocationActivity;
import com.googlecode.gwtphonegap.showcase.client.geolocation.GeolocationPlace;
import com.googlecode.gwtphonegap.showcase.client.media.MediaActivity;
import com.googlecode.gwtphonegap.showcase.client.media.MediaPlace;
import com.googlecode.gwtphonegap.showcase.client.notification.NotificationActivity;
import com.googlecode.gwtphonegap.showcase.client.notification.NotificationPlace;
import com.googlecode.gwtphonegap.showcase.client.plugin.ChildBrowserActivity;
import com.googlecode.gwtphonegap.showcase.client.plugin.ChildBrowserPlace;

/**
 * @author Daniel Kurka
 * 
 */
public class PhoneActivityMapper implements ActivityMapper {

	private final ClientFactory clientFactory;

	public PhoneActivityMapper(ClientFactory clientFactory) {
		this.clientFactory = clientFactory;
	}

	@Override
	public Activity getActivity(Place place) {
		if (place instanceof OverviewPlace) {
			return new OverviewActivity(clientFactory);
		}
		if (place instanceof AccelerometerPlace) {
			return new AccelerometerActivity(clientFactory);
		}

		if (place instanceof CameraPlace) {
			return new CameraActivity(clientFactory);
		}

		if (place instanceof CompassPlace) {
			return new CompassActivity(clientFactory);
		}

		if (place instanceof ConnectionPlace) {
			return new ConnectionActivity(clientFactory);
		}

		if (place instanceof ContactPlace) {
			return new ContactActivity(clientFactory);
		}

		if (place instanceof DevicePlace) {
			return new DeviceActivity(clientFactory);
		}

		if (place instanceof EventPlace) {
			return new EventActivity(clientFactory);
		}

		if (place instanceof GeolocationPlace) {
			return new GeolocationActivity(clientFactory);
		}

		if (place instanceof MediaPlace) {
			return new MediaActivity(clientFactory);
		}

		if (place instanceof NotificationPlace) {
			return new NotificationActivity(clientFactory);
		}

		if (place instanceof ChildBrowserPlace) {
			return new ChildBrowserActivity(clientFactory);
		}

		if (place instanceof AboutPlace) {
			return new AboutActivity(clientFactory);
		}

		if (place instanceof FilePlace) {
			return new FileActivity(clientFactory);
		}

		return null;

	}
}
